<?php
hc_core_ClassLoader::load('halo_AbstractUrlHandlerMapping');
class halo_SimpleUrlHandlerMapping extends halo_AbstractUrlHandlerMapping {
    protected $mappings;
    protected $useDefault;
    public function __construct(array $mappings, $default = null) {
        $this->mappings = $mappings;
        $this->default = $default;
        if ( $default !== null ) {
            $this->useDefault = true;
        } else {
            $this->useDefault = false;
        }
    }
    protected function getHandlerInternal(halo_HttpRequest $httpRequest) {
        $url = $httpRequest->getRequestedUrl();
        if ( $this->useDefault and ( $url === null or $url === '' ) and $this->default !== null ) {
            return $this->context->get($this->default);
        }
        if ( isset($this->registeredHandlers[$url]) ) {
            return $this->context->get($this->registeredHandlers[$url]);
        }
        return null;
    }
    protected function registerHandlers() {
        foreach ( $this->mappings as $url => $objectName ) {
            $this->registerHandler($url, $objectName);
        }
    }
}
?>
